#include <iostream>
#include <stack>
#include <list>
template<class T>
bool judge(std::list<T>&list1){
    std::stack<T> stack1;
    int count=list1.size();
    auto it=list1.begin();
    int i;
    for (i=0;2*i<(count-1);i++){
        stack1.push(*it);
        it++;
    }
    
    for (int j=i;j<count;j++){
        if (2*i==count-1)continue;
        if (stack1.top()!=*it){return false;}
        stack1.pop();
        if (i!=count-1)it++;
    }
    return true;
}

int main(){
    std::list<int> list1={1,2,4,2,1};
    int a=(int)judge(list1);
    std::cout<<a<<std::endl;
    return 0;
}